<template>
	<view class="mian">
		<!-- #ifdef MP-WEIXIN -->
			<navbar :bgColor="bgColor" :btnColors='btnColor' title="积分明细" :isGoBack="true" :isNotice="true" :visible="true"></navbar>
		<!-- #endif -->	
		
		<view class="flex flex-direction bg-white mt-20" style="height: 100vh;">
			<swiper class="tab-content"  duration="300" bindchange="changeTab" :style="{'height':winHeight+'px'}">
				<!-- 全部 -->
				<swiper-item>
					<scroll-view :enhanced="true"
			 :bounces="false" :show-scrollbar="false"  :scroll-y="true" :scroll-x="false" class="new-list-box" @scrolltolower="allLoadMore" scroll-top="scrollTop" scroll-with-animation :refresher-enabled="true" refresher-threshold="80" refresher-default-style="white" refresher-background="white" :refresher-triggered="triggered" @refresherrefresh="onAllRefresh">
						<block v-for="(item,index) in allTabList" :key="index">
							<view class="flex points_mian mt-20 border-b pb-20  pl-30 pr-20 pt-20" >
								<view class="flex justify-between align-center text-center" style="width: 100%;">
									<view class="flex">
										<text class="sign_name">剩余：</text>
										<text style="color: #287EE4;">{{item.accountPoints}}</text>
									</view>
									
									<view class="flex mr-20">
										<text class="sign_name" v-if="item.type==1">签到</text>
										<text v-if="item.style==0" style="color: red;;">-</text>
										<text v-if="item.style==1" style="color: #1EC157;;">+</text>
										<text class="ml-10" :class="item.style==1 ? 'special-class' : 'normal-class'">{{item.affectPoints}}</text>
									</view>
									<text style="font-size: 25rpx; color: #999999;;">{{item.add_time}}</text>
								</view>		
							</view>
						</block>			
				    </scroll-view>
				</swiper-item>       
			</swiper>
		</view>
		
			
	</view>	
</template>
 
<script>
	// import {
	// 	signInRecord
	// } from '@/api/signIn.js'
	export default {
		data() {
			return {
				...getApp().globalData.config,									
				date:'',
				money1:0,
				money2:0,
				pageNo:1,
				allTabList:[],
				winHeight:'',
				scrollTop: 0, // 设置竖向滚动条位置
				triggered: false, // 下拉是否激活
				recordCount:1,
			};
		},
		onLoad() {
			let height = uni.getSystemInfoSync().windowHeight;
			this.winHeight = (height - 100);
		},
		onShow(){
			let pageNo=1
			this.allTabList=[]
			this._requestPageList(true);
		},
		methods: {
			
			// 参数
			_requestPageList(isLoadMore = false, callback) {
			  if(!isLoadMore){
				this.allTabList=[]; // 全部       
				this.pageNo= 1;				
			  }
			  let opt = {
				page :this.pageNo,				
				token:uni.getStorageSync('userInfo').token,
			  }    
			  this._requestPageListCom("virtualTaskList", opt, callback);
			},
			// 列表接口
			_requestPageListCom(url, params, callback) {    
			  this.$http.pointlog_list(params).then(res => {
				if (res.resCode == "9999") {
					this.date=res.data.date
					this.money1=res.data.money1
					this.money2=res.data.money2
					
				  let oldList = [];
				  oldList = this.allTabList;       
				  const newGoodsList = res.data.list
				  const allData = [...oldList, ...newGoodsList] 
				  this.allTabList=allData
				   this.recordCount=res.data.page
				  if(callback && typeof callback === 'function'){
					callback()
				  }
				}
			  })
			},			  
			// 上拉加载  滚动到底部/右边时触发
			allLoadMore(e){
				let _self = this;
				if (this._allLoadMore) return
				this._allLoadMore = true;
				this.pageNo= ++_self.pageNo				
				this._requestPageList(true, () => {
				  _self._allLoadMore = false;
				});
			},
			
			// 下拉刷新接口
			onAllRefresh() {
			 // 开启下拉自定义样式
				this.triggered = true;
			    this.pageNo=1;
				this._requestPageList(false, () => {
					// 当处理完数据刷新后，wx.stopPullDownRefresh可以停止当前页面的下拉刷新
					this.triggered = false;
				});    
			}		
		},
	};
</script>
 
<style scoped lang="scss">
	page{
	 	background-color: #fff;
		overflow:hidden;
	}
	.special-class{
		color: #1EC157;
	}
	.normal-class{
		color:red;
	}
	.sign_name{
		color: #000000;
	}
	.new-list-box {
	 height: 100vh;
	 width: 750rpx;
	} 
	
	scroll-view,view,.wx-scroll-view,.my-scroll{
		  -webkit-overflow-scrolling: auto !important;
		  overscroll-behavior: none !important;
}
	.uni-scroll-view{
	  overscroll-behavior: none;
	}

.point_title{
	font-weight: 600;
	font-size: 30rpx;
	color: #333333;
}

.point_val{
	font-weight: 400;
	font-size: 28rpx;
	color: #777777;
	padding-right: 30rpx;
}
.points_mian{
	display: flex;
	
	background: #fff;
	
	
}
</style>